package com.etms.controller;

import com.etms.pojo.SysUser;
import com.etms.service.RukuService;
import com.etms.vo.PageParmas;
import com.etms.vo.Result;
import com.etms.vo.RukuParmas;
import com.etms.vo.TuihuoParmas;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@RestController
@RequestMapping("ruku")
public class RukuController {
    @Autowired
    RukuService rukuService;

    @PostMapping("updateOrAdd")
    public Result updateOrAdd(@RequestBody RukuParmas rukuParmas, HttpSession session){
        SysUser user = (SysUser) session.getAttribute("user");
        Integer id = user.getId();
        return rukuService.updateOrAdd(rukuParmas,id);
    }


    @GetMapping("quxiaotuihuo/{id}")
    public Result quxiaotuihuo(@PathVariable("id") Integer id){
        return rukuService.quxiaotuihuo(id);
    }
    @PostMapping("getList")
    public Result getList(@RequestBody PageParmas pageParmas){
        return rukuService.getList(pageParmas);
    }

    @PostMapping("tuihuo2")
    public Result tuihuo2(@RequestBody TuihuoParmas tuihuoParmas){
        return rukuService.tuihuo2(tuihuoParmas);
    }
    @GetMapping("getById/{id}")
    public Result getById(@PathVariable("id") Integer id){
        return rukuService.getById(id);
    }

    @GetMapping("daochuById/{id}")
    public Result daochuById(@PathVariable("id") Integer id){
        return rukuService.daochuById(id);
    }

    @GetMapping("del/{id}")
    public Result del(@PathVariable("id") Integer id){
        return rukuService.del(id);
    }

    @GetMapping("tuihuo/{id}")
    public Result tuihuo(@PathVariable("id") Integer id){
        return rukuService.tuihuo(id);
    }

    @GetMapping("getTuiList")
    public Result getTuiList(){
        return rukuService.getTuiList();
    }


}
